/**
* Copyright (c) By zengqh.
*
* This program is just for fun or demo, in the hope that it  
* will be useful, you can redistribute it and/or modify freely.
*
* Time: 2013/03/04
* File: RenderSystem.h
**/

#pragma once

#include "Texture2D.h"
#include "TextureCube.h"
#include "VertexBuffer.h"
#include "IndexBuffer.h"
#include "RenderTarget2D.h"
#include "RenderTargetCube.h"
#include "VertexShader.h"
#include "PixelShader.h"
#include "Program.h"
#include <math/rect.h>
#include <math/color.h>

namespace HY
{
class RenderSystem : public Noncopyable
{
public:
	virtual Texture2D* createTexture2D() = 0;

	virtual TextureCube* createTextureCube() = 0;

	virtual RenderTarget2D* createRenderTarget2D() = 0;

	virtual RenderTargetCube* createRenderTargetCube() = 0;

	virtual VertexBuffer* createVertexBuffer() = 0;

	virtual IndexBuffer* createIndexBuffer() = 0;

	virtual VertexShader* createVertexShader() = 0;

	virtual PixelShader* createPixelShader() = 0;

	virtual Program* createProgram() = 0;

	virtual uint32 getRenderState(uint32 state) const = 0;

	virtual bool setRenderState(uint32 state, uint32 value) = 0;

	virtual bool setProgram(Program* pro) = 0;

	virtual bool beginScene() = 0;

	virtual bool endScene() = 0;

	virtual const IntRect& getViewport() const = 0;

	virtual bool setViewport(const IntRect& viewport) = 0;

	virtual void getColorMask(bool& red, bool& green, bool& blue, bool& alpha) const;

	virtual bool setColorMask(
		bool red = true, 
		bool green = true, 
		bool blue = true, 
		bool alpha = true) = 0;

	virtual bool clear(
		uint32 flags = Clear::Color | Clear::ZBuffer, 
		Color clr = Color::BLACK, float z = 1.0f);

	virtual RenderObject* getRenderTarget() const = 0;

	virtual bool setRenderTarget(RenderObject* rtt) = 0;

	virtual IndexBuffer* getIndexBuffer() = 0;

	virtual bool setIndexBuffer(IndexBuffer* ibuffer) = 0;

	virtual VertexBuffer* getVertexBuffer() = 0;

	virtual bool setVertexBuffer(VertexBuffer* vbuffer) = 0;

	virtual bool drawPrimitives(uint32 type, uint32 start_idx, uint32 num_vertices) = 0;

	virtual bool drawIndexedPrimitives(
		uint32 type, uint32 min_idx, uint32 max_idx, 
		uint32 start_idx, uint32 num_vertices) = 0;

protected:
	RenderSystem() {};
	virtual ~RenderSystem() {}

};
}